const webpack = require('webpack')
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
    entry: ['./app/src/index.jsx'],
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'bundle.js'
    },
    module: {
        rules: [
            {
                test: /\.jsx?$/,
                exclude: (/node_modules|bower_components/),
                use: ['babel-loader']
            },
            {
                test: /\.less$/,
                use: ['style-loader', 
                    {
                        loader:'css-loader',
                        options: {
                            modules: false // open css-modules
                        }
                    }
                    ,'less-loader']
            },
            {
                test: /\.css$/,
                use: ['style-loader','css-loader']
            },
            {
                test: /\.(png|jpe?g|gif|svg)(\?.*)?$/, //
                use: [
                    {                
                        loader: 'url-loader',
                        options: {
                            limit: 10000
                        }
                    },
                    {
                        loader: 'image-webpack-loader',// 压缩图片
                        options: {
                            bypassOnDebug: true,
                        }
                    }
                ]
            },
            {
                test: /\.(woff|woff2|eot|ttf|otf)$/,
                loader: 'file-loader'
            }
        ]
    },
    devServer:{
        port: 8080,
        hot: true,
        open: true
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './app/public/index.html'
        })
    ]
}